package models.mappers;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import vos.ShopSearchVo;
import vos.ShopVo;
import models.Shop;
import models.ShopStatus;
import models.Standard;

public interface ShopMapper {
	/**
	 * 统计列表行数
	 *
	 * @Title: countHraDetail 
	 * @param vo
	 * @return
	 * @return: long
	 */
	long countShop(ShopSearchVo vo);
	/**
	 * 获取列表数据
	 *
	 * @Title: listHraStandard 
	 * @param vo
	 * @return
	 * @return: List<Standard>
	 */
	List<Shop> listShop(ShopSearchVo vo);
	/**
	 * 批量启用门店
	 *
	 * @Title: betchEnable 
	 * @param listid 门店id列表
	 * @return
	 * @return: Boolean
	 */
	void betchEnable(Map<String, Object> map);
	/**
	 * 批量停用门店
	 *
	 * @Title: betchEnable 
	 * @param listid 门店id列表
	 * @return
	 * @return: Boolean
	 */
	void betchDisable(Map<String, Object> map);
	/**
	 * 批量删除门店
	 *
	 * @Title: betchDel 
	 * @param map
	 * @return: void
	 */
	void betchDel(Map<String, List<String>> map);
	/**
	 * 根据id删除门店
	 *
	 * @Title: delShop 
	 * @param id
	 * @return: void
	 */
	@Delete("delete from "
			+ Shop.TABLE_NAME
			+" where shopid=#{id}")
	void delShop(String id);
	/**
	 * 根据id判断是否存在该门店
	 *
	 * @Title: checkCode 
	 * @param shopid
	 * @return
	 * @return: String
	 */
	@Select("select 1 from "
			+ Shop.TABLE_NAME
			+" where shopid=#{shopid}")
	String checkCode(String shopid);
	/**
	 * 根据id获取门店信息
	 *
	 * @Title: getById 
	 * @param shopid 门店id
	 * @return
	 * @return: Shop
	 */
	@Select("select * from shop_view"
			+" where shopid=#{shopid}")
	ShopVo getById(String shopid);
	/**
	 * 保存门店信息
	 *
	 * @Title: saveShop 
	 * @param shop
	 * @return: void
	 */
	@Insert("insert into "
			+ Shop.TABLE_NAME
			+" (shopid,shopname,shopaddress,resperson,resmobile,isflag,createtime,createname,remark,dealerid,regionid,shopstreet,opendate,statusid,organization,space,deposit) values"
			+ "(#{shopid},#{shopname},#{shopaddress},#{resperson},#{resmobile},#{isflag},#{createtime},#{createname},#{remark},#{dealerid},#{regionid},#{shopstreet},#{opendate},#{statusid},#{organization},#{space},#{deposit})")
	void saveShop(Shop shop);
	/**
	 * 更新门店信息
	 *
	 * @Title: updateShop 
	 * @param shop
	 * @return: void
	 */
	@Update("update "
			+ Shop.TABLE_NAME
			+" set shopname=#{shopname},shopaddress=#{shopaddress},"
			+ "resperson=#{resperson},resmobile=#{resmobile},"
			+ "isflag=#{isflag},modifyname=#{modifyname},"
			+ "modifytime=#{modifytime},remark=#{remark},"
			+ "dealerid=#{dealerid},regionid=#{regionid},"
			+ "shopstreet=#{shopstreet},opendate=#{opendate},"
			+ "statusid=#{statusid},organization=#{organization},"
			+ "space=#{space},deposit=#{deposit}"
			+ " where shopid=#{shopid}")
	void updateShop(Shop shop);
	/**
	 * 根据经销商查询门店列表
	 *
	 * @Title: selectByDealer 
	 * @param dealerid
	 * @return
	 * @return: List<Shop>
	 */
	@Select("select shopid from "
			+ Shop.TABLE_NAME
			+" where dealerid=#{dealerid}")
	List<String> selectByDealer(String dealerid);
	/**
	 * 根据经销商id集合查询门店集合
	 *
	 * @Title: selectByDealers 
	 * @param map
	 * @return
	 * @return: List<Shop>
	 */
	List<String> selectByDealers(Map<String, List<String>> map);
	/**
	 * 根据门店id获取视图
	 *
	 * @Title: getViewById 
	 * @param id
	 * @return
	 * @return: ShopVo
	 */
	@Select("select * from shop_view"
			+ " where shopid=#{id}")
	ShopVo getViewById(String id);
	@Select("select shopid,shopname from "
			+ Shop.TABLE_NAME
			+" where isflag=false")
	List<Shop> getCombobox();
	/**
	 * 根据经销商统计门店
	 *
	 * @Title: countShopByDealer 
	 * @param vo 经销商id
	 * @return
	 * @return: long
	 */
	long countShopByDealer(ShopSearchVo vo);
	/**
	 * 根据经销商获取门店列表
	 *
	 * @Title: getShopByDealer 
	 * @param vo 经销商id
	 * @return
	 * @return: List<Shop>
	 */
	List<Shop> getShopByDealer(ShopSearchVo vo);
	/**
	 * 根据id获取VO
	 *
	 * @Title: getVoById 
	 * @param shopid
	 * @return
	 * @return: Shop
	 */
	@Select("select * from "
			+ "shop_view"
			+ " where shopid=#{shopid}")
	ShopVo getVoById(String shopid);
	/**
	 * 导出为excel
	 *
	 * @Title: exportXls 
	 * @param vo
	 * @return
	 * @return: List<ShopVo>
	 */
	List<ShopVo> exportXls(ShopSearchVo vo);
	/**
	 * 查找门店状态下拉框
	 *
	 * @Title: getStatusCombobox 
	 * @return
	 * @return: List<ShopStatus>
	 */
	@Select("select * from shop_status")
	List<ShopStatus> getStatusCombobox();
	/**
	 * 获取所有门店id列表
	 *
	 * @Title: listShopid 
	 * @return
	 * @return: List<String>
	 */
	@Select("select shopid from shop")
	List<String> listShopid();
	/**
	 * 根据ids获取门店对象
	 *
	 * @Title: getByIds 
	 * @param shops
	 * @return
	 * @return: List<Shop>
	 */
	List<Shop> getByIds(List<String> shops);
	
}
